package edu.moravian.UI;

import edu.moravian.managers.EnemyManager;
import edu.moravian.managers.EnemySendThread;
import edu.moravian.managers.WaveGenerator;
import edu.moravian.math.Point2D;
import edu.moravian.player.PlayerInfo;
import edu.moravian.world.World2D;
import edu.moravian.world.WorldDescriptor;
import java.awt.Color;
import java.awt.Font;

public class SendWaveView extends GameView
{
    private WaveGenerator waveGenerator;
    private EnemyManager enemyManager;
    
    public SendWaveView(WorldDescriptor world, WaveGenerator waveGenerator, EnemyManager enemyManager)
    {
        super(world);
        this.waveGenerator = waveGenerator;
        this.enemyManager = enemyManager;
    }

    @Override
    public void draw(World2D w2d)
    {
        w2d.setColor(Color.WHITE);
        w2d.setOpacity(0.5f);
        w2d.drawCenteredRectangle(boundsDescriptor.getCenter(), boundsDescriptor.getWidth()-2, boundsDescriptor.getHeight()-2);
        w2d.setOpacity(1.0f);
        
        
        
        if(waveGenerator.hasNextWave())
        {
            w2d.setColor(Color.BLACK);
            int fontSize = 25;
            Font oldFont = w2d.getFont();
            Font newFont = new Font(oldFont.getName(), oldFont.getStyle(), fontSize);
            w2d.setFont(newFont);
            w2d.drawMiddleCenteredString("Send Wave", boundsDescriptor.getCenter());
            w2d.setFont(oldFont);
        }
        
    }

    @Override
    public void handleMouseClick(Point2D location)
    {
        if (waveGenerator.hasNextWave())
        {
            PlayerInfo.setWave(PlayerInfo.getWave() + 1);
            new Thread(new EnemySendThread(waveGenerator, enemyManager)).start();
        }
    }

    @Override
    public void handleMouseMoved(Point2D location)
    {
        // do nothing
    }

}